package com.zoe.app.config;

import com.zoe.app.entity.Minio;
import io.minio.MinioClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zoe.Zhang
 * @date 2022/06/27
 * @description
 */
@Configuration
public class MinioConfig {
    @Bean
    @ConfigurationProperties(prefix = "minio")
    public Minio minio() {
        Minio minio = new Minio();
        return minio;
    }

    @Bean
    public MinioClient minioClient(Minio minio) {
        MinioClient build = MinioClient.builder()
                                       .endpoint(minio.getEndpoint())
                                       .credentials(minio().getAccessKey(), minio().getSecretKey())
                                       .build();
        return build;
    }
}

